package com.pavan.gps;




import android.app.ListActivity;
import android.content.Intent;
import android.database.Cursor;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.widget.SimpleCursorAdapter;

import com.pavan.nightgps.R;

public class GpsLocDetailsActivity extends ListActivity {
    /** Called when the activity is first created. */
	private DbHelper DbHelper;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.show_loc);
        /*DbHelper = new DbHelper(this);
        DbHelper.open();
        filldata();
        registerForContextMenu(getListView());
        */
        
    }
    
    //private void filldata() {
    	//To get lists from the list table in database
        
     //		Cursor listsCursor = DbHelper.getAllLists();
     	//	startManagingCursor(listsCursor);
     		
     		/*
     		 * This create two arrays, from and to. It maps where column form data base should be displayed
     		 */
     /*		String[] from1 = new String[] {DbHelper.LATITUDE};
     		String[] from2 = new String[] {DbHelper.LONGITUDE};
     		
     		int[] to1 = new int[] {R.id.ListRowText1};
     		int[] to2 = new int[] {R.id.ListRowText2};
     		
     		SimpleCursorAdapter location1 = new SimpleCursorAdapter(this, R.layout.list_view, listsCursor, from1, to1);
     		SimpleCursorAdapter location2 = new SimpleCursorAdapter(this, R.layout.list_view, listsCursor, from2, to2);
     		setListAdapter(location1);
     		setListAdapter(location2);
	}*/

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		MenuInflater inflater = getMenuInflater();
		inflater.inflate(R.menu.main_menu, menu);
		return super.onCreateOptionsMenu(menu);
	}
	
	@Override
	public boolean onOptionsItemSelected(MenuItem item) 
	{
		if(item.getItemId() == R.id.addLoc)
		{
			addLoc();
		}
		if(item.getItemId() == R.id.start)
		{
			startSearching();
		}
		
		return super.onOptionsItemSelected(item);
	}

	private void startSearching() 
	{
		Intent j = new Intent(this, GPSLocationActivity.class);
		startActivity(j);
	}

	private void addLoc() {
		Intent i = new Intent(this, addLoc.class);
		startActivity(i);
		
	}
}